home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 05.zip / BS1 part 5 / PDraw3.0.adf / pdraw_rex.lzh / StyleTagApply.pdrx < prev    next >
Text File  |  1992-06-15  |  3KB  |  109 lines

  1. /*
  2. @N
  3.  
  4. This Genie will apply a previously defined style to the current selection of objects.
  5. */
  6. cr = '0a'x
  7. styledb    = "S:PDStyles.db"
  8. call pdm_AutoUpdate(0)
  9. call pdm_SetBatchMode(1)
  10.  
  11. /*    initialize variables        */
  12. linecolor     = ''
  13. lineweight    = ''
  14. linepattern    = ''
  15. linejoin    = ''
  16. FillPattern    = ''
  17.  
  18.  
  19. if ~open(file, styledb, "r") then
  20.     exit_msg("No styles have been defined. Used AddStyleTag Genie to create a style tag.")
  21.  
  22. lines = ''
  23. counter = 0
  24.  
  25. call pdm_ShowStatus("Reading style database..")
  26.  
  27. do while ~eof(file)
  28.  
  29.     line = strip(readln(file))
  30.  
  31.     if line = '' then iterate
  32.  
  33.     parse var line stylename '@' line
  34.  
  35.     lines = lines || cr || stylename
  36.  
  37.     counter = counter + 1
  38.     linevals.counter.0 = stylename
  39.     linevals.counter.1 = line
  40.  
  41. end
  42.  
  43. call close(file)
  44.  
  45. if counter = 0 then 
  46.     exit_msg("No styles have been defined. Used AddStyleTag Genie to create a style tag.")
  47.  
  48.  
  49. lines = substr(lines,2)
  50.  
  51. nlines = min(max(counter, 5), 10)
  52.  
  53. stylename = pdm_SelectFromList("Select style to apply..", 30, nlines, 0, lines)
  54. if stylename = '' then exit_msg()
  55.  
  56. do i = 1 to counter
  57.  
  58.     if linevals.i.0 = stylename then leave
  59.  
  60. end
  61.  
  62. line = linevals.i.1
  63. parse var line linecolor '@' lineweight '@' linepattern '@' linejoin '@' fillpattern '@'
  64. colorlist = pdm_GetColorList()
  65.  
  66. if linecolor ~= '' then 
  67. do
  68.     parse var linecolor color ';' cdef ';'
  69.     parse var cdef red ',' green ',' blue ',' y ',' m ',' c ',' k ',' flag 
  70.  
  71.     if pos(color, colorlist) = 0 then
  72.         call pdm_DefineColor(color, red, green, blue, y, m, c, k, flag)
  73.     pdm_SetLineColor(, color)
  74. end
  75.  
  76. if lineweight ~= '' then call pdm_SetLineWeight(, lineweight)
  77. if linepattern ~= '' then call pdm_SetLinePattern(, word(linepattern, 1), subword(linepattern, 2))
  78. if linejoin ~= '' then call pdm_SetLineJoin(, linejoin)
  79.  
  80.  
  81. if fillpattern ~= '' then
  82. do
  83.         parse var fillpattern type ';' cdef1 ';' color1 ';' cdef2 ';' color2 ';' steps ';' angle ';' centerx ';' centery ';' 
  84.     parse var cdef1 red ',' green ',' blue ',' y ',' m ',' c ',' k ',' flag 
  85.     
  86.     if pos(color1, colorlist) = 0 then
  87.         call pdm_DefineColor(color1, red, green, blue, y, m, c, k, flag)
  88.  
  89.     parse var cdef2 red ',' green ',' blue ',' y ',' m ',' c ',' k ',' flag 
  90.     
  91.     if pos(color2, colorlist) = 0 then
  92.         call pdm_DefineColor(color2, red, green, blue, y, m, c, k, flag)
  93.  
  94.     call pdm_SetFillPattern(,type, color1, color2, steps, angle, centerx, centery)
  95. end
  96.  
  97. exit_msg()
  98.  
  99. exit_msg: procedure
  100. do
  101.     parse arg message
  102.  
  103.     if message ~= '' then call pdm_inform(1,message,)
  104.     call pdm_SetBatchMode(0)
  105.     call pdm_ClearStatus()
  106.     call pdm_AutoUpdate(1)
  107.     exit
  108. end
  109.